import dayjs from 'dayjs';
import axiosInstance from '@/api/axiosRequest';
import {Res} from '@/api/base';

export interface ContentDataRecord {
  x: string;
  y: number;
}

export function queryContentData() {
  const presetData = [ 383850, 383850*3, 383850*3.5, 383850*4,  383850*1.1];
  const getLineData = () => {
    const count = 5;
    return new Array(count).fill(0).map((el, idx) => ({
      x: dayjs()
        .day(idx*30 - 120)
        .format('YYYY-MM'),
      y: presetData[idx],
    }));
  };
  return {
    data:getLineData()
  };
}

export function listServiceCatalog() {
  return axiosInstance.post<Res>('/omc/serviceProject/listServiceCatalog',{
  })
}

export function retreat(orderId:number) {
  return axiosInstance.post<Res>('/omc/serviceOrder/retreat/'+orderId,{})
}

export function merchantConfirm(orderId:number) {
  return axiosInstance.post<Res>('/omc/serviceOrder/merchantConfirm/'+orderId,{})
}

export function orderReview(params: any) {
  return axiosInstance.post<Res>('/omc/serviceOrder/orderReview',params)
}

export function tipsOkById(params: any) {
  return axiosInstance.post<Res>('/omc/serviceOrder/tipsOkById',params)
}

export function getCameraUrl(params: any) {
  return axiosInstance.post<Res>('/dmc/yingShiChannel/getPlayUrl',params)
}


export function queryProjectList(catalogId:number|null,specialName:string) {
  return axiosInstance.post<Res>('/omc/serviceProject/queryProjectList',{
    specialName: specialName,
    catalogId:catalogId,
    isUse:1
  })
}
export function queryPackageList() {
  return axiosInstance.post<Res>('/omc/servicePackage/queryPackagePage',{
    isUse:1
  })
}

export function getAllOld(params:any) {
  return axiosInstance.post<Res>('/omc/Oldman/selectJTOldman',params)
}

export function getAllStaff(params:any) {
  return axiosInstance.post<Res>('/uac/staff/allListPage',params)
}


export function queryPendingOrderList(queryModel:any) {
  return axiosInstance.post<Res>('/omc/serviceOrder/listPage',{
    statusList:[0,6],
    pageNum: queryModel.pageNum,
    isUse:1
  })
}

export function reviewList(queryModel:any) {
  queryModel.startTime = null;
  queryModel.endTime = null;
  if(queryModel.timeArr.value!=null && queryModel.timeArr.value.length>1){
    queryModel.startTime = queryModel.timeArr.value[0];
    queryModel.endTime = queryModel.timeArr.value[1];
  }
  return axiosInstance.post<Res>('/omc/serviceOrder/reviewList',{
    oldmanName: queryModel.oldmanName.value,
    community: queryModel.community.value,
    userNameGet: queryModel.userNameGet.value,
    groupId: queryModel.groupId.value,
    startTime: queryModel.startTime,
    endTime: queryModel.endTime,
    pageNum: queryModel.pageNum,
    reviewStatus:queryModel.reviewStatus
  })
}

export function queryOrderList(queryModel:any) {
  queryModel.startTime = null;
  queryModel.endTime = null;
  if(queryModel.timeArr.value!=null && queryModel.timeArr.value.length>1){
    queryModel.startTime = queryModel.timeArr.value[0];
    queryModel.endTime = queryModel.timeArr.value[1];
  }
  let statuList:any[] = [];
  console.log(queryModel.statusList.value);
  queryModel.statusList.value.forEach((item:any)=>{
    if(item == "0"){
      statuList.push(0);
      statuList.push(6);
    }else if(item == "4"){
      statuList.push(1);
      statuList.push(2);
      statuList.push(3);
      statuList.push(4);
    }else if(item == "5"){
      statuList.push(5);
    }else if(item == "7"){
      statuList.push(7);
    }else if(item == "8"){
      statuList.push(8);
    }
  })
  return axiosInstance.post<Res>('/omc/serviceOrder/listPage',{
    oldmanName: queryModel.oldmanName.value,
    oldmanCard: queryModel.oldmanCard.value,
    orderSource: queryModel.orderSource.value,
    statusList: statuList,
    isAbnormal: queryModel.isAbnormal.value,
    community: queryModel.community.value,
    userNameGet: queryModel.userNameGet.value,
    specialName: queryModel.specialName.value,
    groupId: queryModel.groupId.value,
    startTime: queryModel.startTime,
    endTime: queryModel.endTime,
    pageNum: queryModel.pageNum,
  })
}

export function getGroup(type:number) {
  return axiosInstance.post<Res>('/uac/group/getGroupDbList',{
    catalogType:type,
    pageSize:5
  })
}

export function getAllGroup(type:Number) {
  return axiosInstance.post<Res>('/uac/group/getGroupDbList',{
    pageSize:10,
    catalogType:type
  })
}

export function getStaff() {
  return axiosInstance.post<Res>('/uac/staff/allListPage',{
    pageSize:5
  })
}

export function getGroupList(){
  //展示名称,类型,等级?
  const groupList = [
    {
      id: 1,
      groupName:'汉兴街新华家园社区老年人服务中心',
      typeName: "服务网点",
    },
    {
      id: 2,
      groupName:'武汉吉年养老服务有限公司',
      typeName: "服务商",
    },
    {
      id: 3,
      groupName:'武汉市江汉区美宜佳娜莉副食店',
      typeName: "周边商户",
    },
    {
      id: 4,
      groupName:'姑嫂树社区养老院',
      typeName: "养老机构",
    },
    {
      id: 5,
      groupName:'夕阳红为老志愿服务队',
      typeName: "志愿者组织",
    }
  ];
  return groupList;
}

export function getServerList(){
  //服务人员姓名,合计服务次数,所属网点,
  const serverList = [
    {
      id: 11,
      name:"许海英",
      times:1275,
      groupName:'汉兴街新华家园社区老年人服务中心',
    },
    {
      id: 12,
      name:"朱重阳",
      times:575,
      groupName:'汉兴街新华家园社区老年人服务中心',
    },
    {
      id: 13,
      name:"孙想",
      times:375,
      groupName:'汉兴街新华家园社区老年人服务中心',
    },
    {
      id: 14,
      name:"汪梦伟",
      times:275,
      groupName:'汉兴街新华家园社区老年人服务中心',
    },
    {
      id: 15,
      name:"肖榕",
      times:245,
      groupName:'汉兴街新华家园社区老年人服务中心',
    },
  ];
  return serverList;
}

export function queryVolunteerList(){
  //服务人员姓名,合计服务次数,所属网点,
  const volunteerList = [
    {
      id: 11,
      name:"许海英",
      integrate:315,
      groupName:'夕阳红为老志愿服务队',
    },
    {
      id: 12,
      name:"林鑫",
      integrate:365,
      groupName:'社区爱心志愿服务队',
    },
    {
      id: 13,
      name:"王春连",
      integrate:135,
      groupName:'社区党员志愿服务队',
    },
    {
      id: 14,
      name:"占继松",
      integrate:275,
      groupName:'夕阳红为老志愿服务队',
    },
    {
      id: 15,
      name:"朱玉兰",
      integrate:375,
      groupName:'社区党员志愿服务队',
    },
  ];
  return volunteerList;
}

export function queryServiceTypeCount() {
  return axiosInstance.post<Res>('/omc/serviceOrder/orderProjectCount',{
  })
}

export function queryPopularList(params: { type: string }) {
  const imageList = [
    {
      id: 1,
      month:'2023-12',
      clickNumber: '15.3w+',
      title: '杨涛接替陆慷出任外交部美大司…',
      increases: 15,
    },
    {
      id: 2,
      month:'2023-11',
      clickNumber: '12.2w+',
      title: '图集：龙卷风袭击美国多州房屋…',
      increases: 26,
    },
    {
      id: 3,
      month:'2023-10',
      clickNumber: '18.9w+',
      title: '52岁大姐贴钱照顾自闭症儿童八…',
      increases: 9,
    },
    {
      id: 4,
      month:'2023-09',
      clickNumber: '7.9w+',
      title: '杭州一家三口公园宿营取暖中毒',
      increases: 0,
    },
    {
      id: 5,
      month:'2023-08',
      clickNumber: '5.2w+',
      title: '派出所副所长威胁市民？警方调…',
      increases: 4,
    },
  ];
  return imageList;
  // return axios.get<TableData[]>('/api/popular/list', { params });
}
